<template>
  <div class="tab">
    <div v-for="(item, index) of tabData" :key="index" class="tab-item">
      <tab-icon :path="item.path" :iconText="item.iconText">
        {{ item.tabText }}
      </tab-icon>
    </div>    
  </div>
</template>

<script>
import TabIcon from './Icon';

import tabData from '@/datas/tab';
import { reactive, toRefs } from 'vue';

export default {
  name: 'Tab',
  components: {
    TabIcon
  },
  setup () {
    // 定义数据源
    const state = reactive({
      tabData
    })
    return {
      // 将state上的每个属性都转化为ref形式的相应数据
      ...toRefs(state)
    }
  }
}
</script>

<style lang='scss' scoped>
.tab {
  display: flex;
  flex-direction: row;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 1;
  width: 100%;
  height: .44rem;
  border-top: 1px solid #ddd;
  background-color: #fff;

  .tab-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 33.3%;
  }
}
</style>